package com.xinsoft.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinsoft.entity.dto.SysDictTypeParam;
import com.xinsoft.entity.po.SysDictionaryType;
import com.xinsoft.mapper.SysDictionaryTypeMapper;
import com.xinsoft.service.SysDictionaryTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author lijie
 * @description 针对表【sys_dictionary_type(字典类型)】的数据库操作Service实现
 * @createDate 2023-05-16 17:10:08
 */
@Service
public class SysDictionaryTypeServiceImpl extends ServiceImpl<SysDictionaryTypeMapper, SysDictionaryType>
        implements SysDictionaryTypeService {

    @Resource
    SysDictionaryTypeMapper typeMapper;

    @Override
    public Object findPageListByParam(SysDictTypeParam param) {
        //分页
        Page<SysDictionaryType> page = new Page<SysDictionaryType>(param.getCurrentPage(), param.getPageSize());
        LambdaQueryWrapper<SysDictionaryType> queryWrapper = new LambdaQueryWrapper<>();
        //查询条件
        queryWrapper
                .like(StrUtil.isNotBlank(param.getTypeName()), SysDictionaryType::getTypeName, param.getTypeName())
                .eq(param.getDoUpdate() != null, SysDictionaryType::getDoUpdate, param.getDoUpdate())
                .like(StrUtil.isNotBlank(param.getTypeCode()), SysDictionaryType::getTypeCode, param.getTypeCode());
        IPage<SysDictionaryType> resultPage = typeMapper.selectPage(page, queryWrapper);

        //返回值
        return resultPage;
    }
}




